﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Minecraft.WorldMap
{
	public sealed class RegionReader
	{
		public NamedBinaryTag.TagReader ChunkReader
		{
			get
			{
				return currentContext.Reader;
			}
		}

		public int X { get { return currentContext.X; } }

		public int Z { get { return currentContext.Z; } }

		public DateTime Update { get { return currentContext.Update; } }

		internal System.IO.Stream BaseStream { get; private set; }
		internal SectorizedStream SectorStream { get; private set; }

		public int ChunksCount
		{
			get
			{
				throw new System.NotImplementedException();
			}
		}

		public bool[,] ChunksMap
		{
			get
			{
				throw new System.NotImplementedException();
			}
		}

		public RegionReadMode ReadMode
		{
			get
			{
				throw new System.NotImplementedException();
			}
			set
			{
			}
		}

		private ChunkDefinition[] chunks;
		private RegionReaderContext currentContext;
		private int chunkIndex;

		internal RegionReader()
		{
		}

		public static RegionReader Create(System.IO.Stream source)
		{
			RegionReader reader = new RegionReader();
			reader.BaseStream = source;
			reader.SectorStream = new SectorizedStream(source, RegionHelper.sectorSize);
			return reader;
		}

		public static RegionReader Create(System.IO.Stream source, bool randomAccess)
		{
			if (randomAccess && source.CanSeek)
				throw new InvalidOperationException("Not seekable and asked for.");
			RegionReader reader = new RegionReader();
			reader.BaseStream = source;
			reader.SectorStream = new SectorizedStream(source, RegionHelper.sectorSize);
			return reader;
		}

		public bool ReadNext()
		{
			throw new System.NotImplementedException();
		}

		public bool MoveTo(int x, int z)
		{
			throw new System.NotImplementedException();
		}

		public bool Exists(int x, int z)
		{
			throw new System.NotImplementedException();
		}
	}
}
